<!DOCTYPE HTML>
<html>
<head>
    <title>Error</title>
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <script src="/scripts/jquery.min.js"></script>
    <link rel="stylesheet" href="/stylesheets/formdata.css">
    <link rel="stylesheet" href="/scripts/miniui/themes/default/miniui.css">
    <link rel="stylesheet" href="/scripts/miniui/themes/icons.css">
    <link rel="stylesheet" href="/scripts/miniui/themes/bootstrap/skin.css">

    <script src="/scripts/miniui/miniui.js"></script>
    <script src="/qiniuJs/liveFormdata.js"></script>
    <script src="/qiniuJs/livePicFormdata.js"></script>

</head>
<body>
<div class="container" style="display: inline-block;width: 40%; margin: 10px">
    <!-- Document：https://developer.qiniu.com/kodo/manual/form-upload -->
    <form id="testform" method="post" enctype="multipart/form-data">
        <input name="key" id="key" type="hidden" value="">
        <input name="token" type="hidden" value="<%= uptoken %>">
        <input id="userfile" name="file"  accept="audio/mp4,video/mp4"   type="file" />
        <!-- take photo with phone -->
        <!-- <input id="userfile" name="file" accept="image/*" type="file" /> -->
        <!-- take video with phone -->
        <!-- <input id="userfile" name="file" type="file" accept="video/*"/> -->
        <input name="accept" type="hidden" />
    </form>
    <!-- add file -->
    <label for="userfile">
        <span></span>
        <em>添加视频</em>
    </label>

    <!-- upload info -->
    <div class="selected-file"></div>
    <div class="progress"></div>
    <div class="uploaded-result"></div>
</div>
<div class="container"  style="display: inline-block;width: 40%;">
    <!-- Document：https://developer.qiniu.com/kodo/manual/form-upload -->
    <form id="testformPic" method="post" enctype="multipart/form-data">
        <input name="key" id="keyPic" type="hidden" value="">
        <input name="token" type="hidden" value="<%= uptokenPic %>">
        <input id="userfilePic" name="file" style="display: none"  accept="image/*"   type="file" />
        <!-- take photo with phone -->
        <!-- <input id="userfile" name="file" accept="image/*" type="file" /> -->
        <!-- take video with phone -->
        <!-- <input id="userfile" name="file" type="file" accept="video/*"/> -->
        <input name="accept" type="hidden" />
    </form>
    <!-- add file -->
    <label for="userfilePic">
        <span></span>
        <em>添加封面</em>
    </label>

    <!-- upload info -->
    <div class="selected-file-pic"></div>
    <div class="progress-pic"></div>
    <div class="uploaded-result-pic"></div>
</div>
<div id="form1" style="padding-left: 30px">
    <span style="width:80px;display:inline-block;">标题：</span>
    <input id="title" name="title" class="mini-textbox" required="true" style="width:155px;" />

    <span style="width:80px;display:inline-block;">部落：</span>
    <input id="tribeOId" class="mini-buttonedit" onbuttonclick="onButtonEdit"  name="a" textName="b"/>

    <br/><br/>

    <span style="width:80px;display:inline-block;">一级分享：</span>
    <input id="firstLevel" class="mini-textbox"  vtype="float" style="width:155px;"/>

    <span style="width:80px;display:inline-block;">二级分享：</span>
    <input id="lastLevel" name="title" class="mini-textbox" vtype="float" style="width:155px;"  />

    <br/><br/>

    <span style="width:80px;display:inline-block;">创建人：</span>
    <input id="createrOId" class="mini-buttonedit" onbuttonclick="onButtonUser"  name="a" textName="b"/>

    <span style="width:80px;display:inline-block;">公开：</span>
    <input id="isPublic" name="title" class="mini-combobox" required="true" style="width:155px;" data="isPublic" />
    <input id="streambackup"  required="true"  class="mini-textbox" style="display: none"/>
    <input id="coverPic"  required="true"  class="mini-textbox" style="display: none"/>

    <br/><br/>
    <div style="margin: 0 auto;text-align: center">
        <a class="mini-button " iconCls="icon-ok" onclick="updataShop()">确定</a>
        <a class="mini-button" iconCls="icon-cancel" onclick="onCancel">取消</a>
    </div>
</div>
</body>
<script>
    var domain = "<%- domain %>";
    var isPublic = [{id:1,text:"公开"},{id:0,text:"私有"}];
    function updataShop() {
        var form = new mini.Form("#form1");
        form.validate();
        if (form.isValid() == false) {
            alert("请正确填写数据")
            return
        };
        var title = mini.get("title").getValue();
        var tribeOId = mini.get("tribeOId").getValue();
        var createrOId = mini.get("createrOId").getValue();
        var isPublic = mini.get("isPublic").getValue();
        var streambackup = mini.get("streambackup").getValue();
        var coverPic = mini.get("coverPic").getValue();
        var firstLevel = mini.get("firstLevel").getValue();
        var lastLevel = mini.get("lastLevel").getValue();
        var status = 3;
        var isRecord = 2;
        var goods = [];

        $.ajax({
            type: "POST",
            url: "/getdata/updateLive",
            data:{
                title:title,
                tribeOId:tribeOId,
                createrOId:createrOId,
                isPublic:isPublic,
                streambackup:streambackup,
                status:status,
                isRecord:isRecord,
                coverPic:coverPic,
                firstLevel:firstLevel,
                lastLevel:lastLevel,
                browseNum:0,
                goods:goods,
            },

            success: function (result) {
                CloseWindow("save");
            }
        })
    }
    //    关闭窗口
    function CloseWindow(action) {
        if (action == "close" && form.isChanged()) {
            if (confirm("数据被修改了，是否先保存？")) {
                return false;
            }
        }
        if (window.CloseOwnerWindow) return window.CloseOwnerWindow(action);
        else window.close();
    }
    function onOk(e) {
        SaveData();
    }
    function onCancel(e) {
        CloseWindow("cancel");
    }

    function onButtonEdit(e) {
        var btnEdit = this;
        mini.open({
            url: "/editor/tribeChoice",
            title: "选择列表",
            width: 700,
            height: 450,
            ondestroy: function (action) {
                if (action == "ok") {
                    var iframe = this.getIFrameEl();
                    var data = iframe.contentWindow.GetData();
                    data = mini.clone(data);    //必须
                    if (data) {
                        btnEdit.setValue(data.id);
                        btnEdit.setText(data.text);
                    }
                }else {
                    btnEdit.setText("");
                    btnEdit.setValue("");
                }

            }
        });

    }
    function onButtonUser(e) {
        var btnEdit = this;
        mini.open({
            url: "/tribeRoute/tribeMGEditSelectCreater",
            title: "选择列表",
            width: 700,
            height: 450,
            ondestroy: function (action) {
                //if (action == "close") return false;
                if (action == "ok") {
                    var iframe = this.getIFrameEl();
                    var data = iframe.contentWindow.GetData();
                    data = mini.clone(data);    //必须
                    if (data) {
                        btnEdit.setText(data.nickName);
                        btnEdit.setValue(data.objectId);
                    }
                }

            }
        });

    }

</script>
</html>